package lt.registrucentras.tutorial.util;

import static org.junit.Assert.*;
import org.apache.commons.codec.binary.Hex;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * UserEntity: simnau
 * Date: 13.2.8
 * Time: 11.39
 * To change this template use File | Settings | File Templates.
 */
public class InflectorTest {


    @Test
    public void testInflector(){
        String[] names = {"Abdonas", "Albertas", "Adolfas", "Adomas", "Aidas", "Aivaras",
                          "Aleksandras", "Aleksas", "Aloyzas", "Andrėjus", "Andrius",
                          "Audrys", "Augenis", "Augutis", "Ąžuolas", "Boleslovas", "Bonifacas",
                          "Emilis", "Erikas", "Fidelis", "Gabrielius", "Giedrius", "Jaunius",
                          "Jurgis", "Rytis", "Kajus", "Karolis", "Kastytis", "Kęstutis", "Laisvutis",
                          "Liucijus", "Mantvilas", "Marius", "Marijus", "Mečys", "Naglis"};

        String[] surnames = {"Juozapavičius-Jevgenij", "Jonaitis", "Andrijauskas",
                             "Donelaitis", "Kolosovskis", "Butkus", "STANKUS"};

        for (String name : names){
            String genitiveCase = Inflector.getCasedWord(name, Case.GENITIVE);
            System.out.println("Nominitive case: " + name);
            System.out.println("Genitive case  : " + genitiveCase);
            System.out.println("-------------------------");
        }

        System.out.println("\nSURNAMES\n");

        for (String surname : surnames){
            String genitiveCase = Inflector.getCasedWord(surname, Case.GENITIVE);
            System.out.println("Nominitive case: " + surname);
            System.out.println("Genitive case  : " + genitiveCase);
            System.out.println("-------------------------");
        }
    }

    @Test
    public void testInflectorWomenNames(){
        String[] names = {"Paulina", "Agnė", "Pelagija", "Pranciška", "Rachelė",
                "Raimonda", "Raminta", "Ramunė", "Ramutė", "Rasa", "Regina",
                "Roma", "Rožė", "Rūta", "Sabina", "Salomėja", "Sandra", "Pajauta"};


        String[] surnames = {""};

        for (String name : names){
            String genitiveCase = Inflector.getCasedWord(name, Case.GENITIVE);
            System.out.println("Nominitive case: " + name);
            System.out.println("Genitive case  : " + genitiveCase);
            System.out.println("-------------------------");
        }

        System.out.println("\nSURNAMES\n");

        for (String surname : surnames){
            String genitiveCase = Inflector.getCasedWord(surname, Case.GENITIVE);
            System.out.println("Nominitive case: " + surname);
            System.out.println("Genitive case  : " + genitiveCase);
            System.out.println("-------------------------");
        }
    }

    @Test
    public void testInflection() {
        List<TestCase> testCases = new ArrayList<TestCase>();

        testCases.add(new TestCase("Jonas", "Jonaitis", Case.ACCUSATIVE, "Joną", "Jonaitį"));
        testCases.add(new TestCase("Gytis", "Martišius", Case.ACCUSATIVE, "Gytį", "Martišių"));
        testCases.add(new TestCase("Darius", "Vainauskas", Case.ACCUSATIVE, "Darių", "Vainauską"));
        testCases.add(new TestCase("Marytė", "Genytė", Case.ACCUSATIVE, "Marytę", "Genytę"));
        testCases.add(new TestCase("Valerija", "Gervienė", Case.ACCUSATIVE, "Valeriją", "Gervienę"));
        testCases.add(new TestCase("Vladimir", "Putin", Case.ACCUSATIVE, "Vladimir", "Putin"));
        testCases.add(new TestCase("Mečys", "Kolosovskis", Case.ACCUSATIVE, "Mečį", "Kolosovskį"));
        testCases.add(new TestCase("Aurelijus", "Gedminas", Case.ACCUSATIVE, "Aurelijų", "Gedminą"));
        testCases.add(new TestCase("Gaidys", "Gaidys", Case.GENITIVE, "Gaidžio", "Gaidžio"));
        testCases.add(new TestCase("Bildys", "Bildys", Case.ACCUSATIVE, "Bildį", "Bildį"));
        testCases.add(new TestCase("Gaidys", "Gaidys", Case.DATIVE, "Gaidžiui", "Gaidžiui"));
        testCases.add(new TestCase("Gaidys", "Gaidys", Case.INSTRUMENTAL, "Gaidžiu", "Gaidžiu"));
        testCases.add(new TestCase("Burdis", "Burdis", Case.GENITIVE, "Burdžio", "Burdžio"));

        for (TestCase testCase : testCases) {
            assertCase(testCase);
        }
    }

    private void assertCase(TestCase testCase) {
        String resultName = Inflector.getCasedWord(testCase.name, testCase.iCase);
        String resultSurname = Inflector.getCasedWord(testCase.surname, testCase.iCase);

        assertEquals(testCase.expectedName, resultName);
        assertEquals(testCase.expectedSurname, resultSurname);
    }

    private class TestCase {
        String name;
        String surname;
        Case iCase;
        String expectedName;
        String expectedSurname;

        TestCase(String name, String surname, Case iCase, String expectedName, String expectedSurname) {
            this.name = name;
            this.surname = surname;
            this.iCase = iCase;
            this.expectedName = expectedName;
            this.expectedSurname = expectedSurname;
        }
    }
}
